\documentclass{article}
\usepackage{listings}
\begin{document}
main text main \lstinline[basicstyle=\ttfamily]!foobar!.
\end{document}
